package com.adnaan.restaurant.service.impl;

import com.adnaan.restaurant.common.untils.PageResult;
import com.adnaan.restaurant.common.untils.PageUtils;
import com.adnaan.restaurant.entity.ResCollect;
import com.adnaan.restaurant.mapper.ResCollectMapper;
import com.adnaan.restaurant.service.IResCollectService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * author: adnaan
 * create: 2023-12-13 19:22
 * Description:
 */
@Service
public class ResCollectServiceImpl implements IResCollectService {

    @Autowired
    private ResCollectMapper resCollectMapper;

    @Override
    public List<ResCollect> selectResCollectList(ResCollect resCollect) {
        return resCollectMapper.selectResCollectList(resCollect);
    }

    @Override
    public PageResult selectResCollect(Integer pageNum, Integer pageSize, ResCollect resCollect) {
        PageHelper.startPage(pageNum, pageSize);
        List<ResCollect> list = resCollectMapper.selectResCollectList(resCollect);
        PageInfo<ResCollect> resCollectPageInfo = new PageInfo<>(list);
        PageResult pageResult = PageUtils.getPageResult(resCollectPageInfo);
        return pageResult;
    }

    @Override
    public int addCollect(ResCollect resCollect) {
        return resCollectMapper.addCollect(resCollect);
    }

    @Override
    public int cancelCollect(ResCollect resCollect) {
        return resCollectMapper.cancelCollect(resCollect);
    }
}
